package com.csw.searchRecSys.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.csw.searchRecSys.dao.PoemRepository;
import com.csw.searchRecSys.entity.Poem;
import com.csw.searchRecSys.service.PoemService;

@RestController
@RequestMapping("do")
public class documentController {
	@Autowired
	private PoemRepository poemRepository;

	@Autowired
	private ElasticsearchRestTemplate elasticsearchTemplate;
	@Autowired
	private PoemService poemService;

	@RequestMapping("inputclear")
	@ResponseBody
	public void inputclear() {
		poemRepository.deleteAll();
	}

	@RequestMapping("inputreload")
	@ResponseBody
	public void inputreload() {
		List<Poem> poemList = poemService.findAll2();
		poemRepository.saveAll(poemList);
		System.out.println("poemlist;;" + poemList);
//        for (Poem poem : poemList) {
//            poemRepository.save(poem);
//        }
		/*
		 * for (int i = 0; i < poemList.size(); i++) {
		 * System.out.println(poemList.get(i)); poemRepository.save(poemList.get(i)); }
		 */
	}
}
